package fun.chutianshu;

public class Phenix extends Pet implements Fly{


    private boolean isReborn = false;

    public Phenix(int age, String name, int hp, String color, int ap) {
        super(age, name, hp, color, ap);
    }

    public Phenix(){}

    public boolean isReborn() {
        return isReborn;
    }

    public void setReborn(boolean reborn) {
        isReborn = reborn;
    }

    @Override
    public void fly() {
        System.out.println("凤凰" + this.getName()+" 飞舞在九天之上，像一团火焰，染红了周边云彩");
    }

    @Override
    public String toString() {
        return super.toString() + "Phenix{" +
                "isReborn=" + isReborn +
                '}';
    }

    @Override
    public void printPet() {
        System.out.println(this.toString());
    }

    @Override
    public void play() {
        System.out.println("凤凰"+this.getName()+"正在玩耍...");
    }

    public void reborn(){
        if(!this.isReborn() && this.getHp()<=0){
            // 凤凰的初始生命
            this.setHp(this.getInitHp());
            System.out.println("凤凰 "+this.getName()+" 涅槃！浴火重生，生命值回满！！！！");
            this.setReborn(true);
        }
    }
}
